﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using FOModels.HomeLoanTrust;
using DataAccess.HomeLoanTrust;
using System.Net;
namespace Bussiness.HomeLoanTrust
{
    public class HomeLoanTrustBLL
    {
        private HomeLoanTrustDAL dal;
        public HomeLoanTrustBLL()
        {
            dal = new HomeLoanTrustDAL();
        }
        public List<HomeLoanApplyModels> getcontractbycateid(int cateid)
        {
            List<HomeLoanApplyModels> list = new List<HomeLoanApplyModels>();
            HomeLoanApplyModels fur;
            DataTable tb = dal.getcontractbycateid(cateid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanApplyModels();
                    fur.HomeLoanApplyID = int.Parse(row[0].ToString());
                    fur.HomeLoanID = int.Parse(row[1].ToString());
                    fur.CustomerName = row[2].ToString();
                    fur.CustomerEmail = row[3].ToString();
                    fur.CustomerPhone = row[4].ToString();
                    fur.CustomerIncome = row[5].ToString();
                    fur.CustomerDOB = row[6].ToString();
                    fur.StatusID = int.Parse(row[7].ToString());
                    fur.AppDate = row[8].ToString();
                    fur.HomeLoanName = row[10].ToString();
                    fur.StatusName = row[18].ToString();
                    fur.CompanyImg = row[20].ToString();
                    fur.CompanyName = row[27].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<HomeLoanApplyModels> getcontractbystatuscount(int cateid,int statusid)
        {
            List<HomeLoanApplyModels> list = new List<HomeLoanApplyModels>();
            HomeLoanApplyModels fur;
            DataTable tb = dal.getcontractbystatuscount(cateid, statusid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanApplyModels();
                    fur.HomeLoanApplyID = int.Parse(row[0].ToString());
                    fur.HomeLoanID = int.Parse(row[1].ToString());
                    fur.CustomerName = row[2].ToString();
                    fur.CustomerEmail = row[3].ToString();
                    fur.CustomerPhone = row[4].ToString();
                    fur.CustomerIncome = row[5].ToString();
                    fur.CustomerDOB = row[6].ToString();
                    fur.StatusID = int.Parse(row[7].ToString());
                    fur.AppDate = row[8].ToString();
                    fur.HomeLoanName = row[10].ToString();
                    fur.StatusName = row[18].ToString();
                    fur.CompanyImg = row[20].ToString();
                    fur.CompanyName = row[27].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public HomeLoanApplyModels getcontractbyid(int HomeLoanapplyid)
        {

            HomeLoanApplyModels fur = new HomeLoanApplyModels();
            DataTable tb = dal.getcontractbyid(HomeLoanapplyid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanApplyModels();
                    fur.HomeLoanApplyID = int.Parse(row[0].ToString());
                    fur.HomeLoanID = int.Parse(row[1].ToString());
                    fur.CustomerName = row[2].ToString();
                    fur.CustomerEmail = row[3].ToString();
                    fur.CustomerPhone = row[4].ToString();
                    fur.CustomerIncome = row[5].ToString();
                    fur.CustomerDOB = row[6].ToString();
                    fur.StatusID = int.Parse(row[7].ToString());
                    fur.AppDate = row[8].ToString();
                    fur.HomeLoanName = row[10].ToString();
                    fur.StatusName = row[18].ToString();
                    fur.CompanyImg = row[20].ToString();
                    fur.CompanyName = row[27].ToString();

                }
            }
            return fur;
        }
        public int HomeLoanApply(int HomeLoanID, HomeLoanApplyModels HomeLoan)
        {
            if (dal.HomeLoanApply(HomeLoanID, HomeLoan) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteHomeLoanApply(int HomeLoanApplyID)
        {
            if (dal.DeleteHomeLoanApply(HomeLoanApplyID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateStatus(HomeLoanApplyModels HomeLoan)
        {
            if (dal.UpdateStatus(HomeLoan) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public HomeLoanTrustModels getTOP1()
        {

            HomeLoanTrustModels fur = new HomeLoanTrustModels();
            DataTable tb = dal.getTOP1();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {

                    fur.HomeLoanID = int.Parse(row[0].ToString());
                }
                return fur;
            }
            else
                return null;
        }
        public List<HomeLoanPlanModels> getHomeLoanPlan(int langid)
        {
            List<HomeLoanPlanModels> list = new List<HomeLoanPlanModels>();
            HomeLoanPlanModels fur;
            DataTable tb = dal.getHomeLoanPlan(langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanPlanModels();
                    fur.HomeLoanPlanID = int.Parse(row[0].ToString());
                    fur.HomeLoanPlanName = row[4].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<HomeLoanTrustModels> getHomeLoanDefault(int cateid, int langid)
        {
            List<HomeLoanTrustModels> list = new List<HomeLoanTrustModels>();
            HomeLoanTrustModels fur;
            DataTable tb = dal.getHomeLoanDefault(cateid, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanTrustModels();
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<HomeLoanTrustModels> getHomeLoanDefaultByProvider(int cateid, int CompanyID, int langid)
        {
            List<HomeLoanTrustModels> list = new List<HomeLoanTrustModels>();
            HomeLoanTrustModels fur;
            DataTable tb = dal.getHomeLoanDefaultByProvider(cateid, CompanyID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanTrustModels();
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<HomeLoanTrustModels> getHomeLoanMortgageDefault(int cateid, int langid)
        {
            List<HomeLoanTrustModels> list = new List<HomeLoanTrustModels>();
            HomeLoanTrustModels fur;
            DataTable tb = dal.getHomeLoanMortgageDefault(cateid, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanTrustModels();
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<HomeLoanTrustModels> getHomeLoanMortgageDefaultByProvider(int cateid, int CompanyID, int langid)
        {
            List<HomeLoanTrustModels> list = new List<HomeLoanTrustModels>();
            HomeLoanTrustModels fur;
            DataTable tb = dal.getHomeLoanMortgageDefaultByProvider(cateid, CompanyID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanTrustModels();
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<HomeLoanTrustModels> gethomeloamtrustrelati(int cateid, int CompanyID, int HomeLoanID, int langid)
        {
            List<HomeLoanTrustModels> list = new List<HomeLoanTrustModels>();
            HomeLoanTrustModels fur;
            DataTable tb = dal.gethomeloamtrustrelati(cateid, CompanyID, HomeLoanID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanTrustModels();
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<HomeLoanTrustModels> getHomeLoan(int cateid, int planid, string balance, int years, int langid)
        {
            List<HomeLoanTrustModels> list = new List<HomeLoanTrustModels>();
            HomeLoanTrustModels fur;
            DataTable tb = dal.getHomeLoan(cateid, planid, balance, years, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanTrustModels();
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<HomeLoanTrustModels> getHomeLoanByProvider(int cateid, int planid, string balance, int years, int CompanyID, int langid)
        {
            List<HomeLoanTrustModels> list = new List<HomeLoanTrustModels>();
            HomeLoanTrustModels fur;
            DataTable tb = dal.getHomeLoanByProvider(cateid, planid, balance, years, CompanyID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanTrustModels();
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<HomeLoanTrustModels> getHomeLoanMorgage(int cateid, int planid, string balance, int years, int langid)
        {
            List<HomeLoanTrustModels> list = new List<HomeLoanTrustModels>();
            HomeLoanTrustModels fur;
            DataTable tb = dal.getHomeLoanMorgage(cateid, planid, balance, years, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanTrustModels();
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<HomeLoanTrustModels> getHomeLoanMorgageByProvider(int cateid, int planid, string balance, int years, int CompanyID, int langid)
        {
            List<HomeLoanTrustModels> list = new List<HomeLoanTrustModels>();
            HomeLoanTrustModels fur;
            DataTable tb = dal.getHomeLoanMorgageByProvider(cateid, planid, balance, years, CompanyID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanTrustModels();
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.InterestVND = float.Parse(row[27].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public HomeLoanTrustModels getHomeLoanByID(int HomeLoanID, int langid)
        {

            HomeLoanTrustModels fur = new HomeLoanTrustModels();
            DataTable tb = dal.getHomeLoanByID(HomeLoanID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                }
                return fur;
            }
            else
                return null;
        }
        public HomeLoanTrustModels getHomeLoanByIDManager(int HomeLoanID, int langid)
        {

            HomeLoanTrustModels fur = new HomeLoanTrustModels();
            DataTable tb = dal.getHomeLoanByIDManager(HomeLoanID, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = String.Format("{0:0,0}", double.Parse(row[4].ToString())).Replace(',', '.');
                    fur.MaximumBalance = String.Format("{0:0,0}", double.Parse(row[5].ToString())).Replace(',', '.');
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                }
                return fur;
            }
            else
                return null;
        }
        public List<HomeLoanTrustModels> getall(int cateid, int langid)
        {
            List<HomeLoanTrustModels> list = new List<HomeLoanTrustModels>();
            HomeLoanTrustModels fur;
            DataTable tb = dal.getall(cateid, langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {

                    fur = new HomeLoanTrustModels();
                    fur.HomeLoanID = int.Parse(row[0].ToString());
                    fur.HomeLoanName = row[10].ToString();
                    fur.CompanyID = int.Parse(row[2].ToString());
                    fur.HomeLoanCategoryID = int.Parse(row[3].ToString());
                    fur.Benefit = WebUtility.HtmlDecode(row[11].ToString());
                    fur.MinimumBalance = row[4].ToString();
                    fur.MaximumBalance = row[5].ToString();
                    fur.HomeLoanPlanID = int.Parse(row[6].ToString());
                    fur.Description = WebUtility.HtmlDecode(row[12].ToString());
                    fur.FeeContent = WebUtility.HtmlDecode(row[13].ToString());
                    fur.MoreInfo = WebUtility.HtmlDecode(row[14].ToString());
                    fur.Display = bool.Parse(row[7].ToString());
                    fur.CompanyName = row[23].ToString();
                    fur.CompanyImg = row[16].ToString();
                    fur.FlagImage = row[28].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<HomeLoanCategoryModels> getallcarloancate(int langid)
        {
            List<HomeLoanCategoryModels> list = new List<HomeLoanCategoryModels>();
            HomeLoanCategoryModels fur;
            DataTable tb = dal.getallhomeloancate(langid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new HomeLoanCategoryModels();
                    fur.HomeLoanCategoryID = int.Parse(row[0].ToString());
                    fur.HomeLoanCategoryName = row[4].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public int UpdateHomeLoan(HomeLoanTrustModels models, int langid)
        {
            if (dal.UpdateHomeLoan(models) > 0 && dal.UpdateHomeLoanLang(models, langid) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertHomeLoanTrust(HomeLoanTrustModels models)
        {
            if (dal.InsertHomeLoanTrust(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertHomeLoanMortgage(HomeLoanTrustModels models)
        {
            if (dal.InsertHomeLoanMortgage(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertHomeLoanLang(HomeLoanTrustModels models, int langid)
        {
            if (dal.InsertHomeLoanLang(models, langid) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteHomeLoan(int CarLoanID)
        {
            if (dal.DeleteHomeLoanLang(CarLoanID) > 0 && dal.DeleteHomeLoan(CarLoanID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }


    }
}
